package pojo;

import util.Helper;
import util.Verify;

public class UserAttr {
    public static final String TableName   = "pollsys_users";
    
    private int _userId;
    public int getUserId() {
        return this._userId;
    }
    public void setUserId(int userId) {
        this._userId    = userId;
    }
    
    private String _userName;
    public String getUserName() {
        return this._userName;
    }
    public void setUserName(String userName) {
        this._userName  = userName.trim();
    }
    
    private String _userPasswd;
    public String getUserPasswd() {
        return this._userPasswd;
    }
    public void setUserPasswd(String userPasswd) {
        this._userPasswd    = Helper.getMD5Str(userPasswd);
    }
    
    private int _userType;
    public int getUserType() {
        return this._userType;
    }
    public void setUserType(int userType) {
        this._userType  = userType;
    }
    
    private String _userEmail;
    public String getUserEmail() {
        return this._userEmail;
    }
    public void setUserEmail(String userEmail) {
        this._userEmail     = userEmail.trim();
    }
    
    private String _createTime;
    public String getCreateTime() {
        return this._createTime;
    }
    public void setCreateTime(String createTime) {
        this._createTime    = createTime;
    }
   
    /**
     * 验证信息是否合法 
     */
    public String validate() {
        if(this._userName.equals("")||  this._userEmail.equals("")) {
            return "用户名及邮箱地址不能为空！";
        }
        if(false == Verify.isValidLen(this._userName, 40)) {
            return "用户名长度不能超过40个字符！";
        }
        return null; 
    }
    
}
